export const env = process.env.NODE_ENV === 'development' ? 'dev'
    : process.env.APP_ENV === 'test' ? 'test' : 'prod';

export const envConfig = process.env.ENV_CONFIG as any as {
    baseURL: string
};

export const noop = () => {};

// 初始url参数
export const initParams = (() => {
    type TstrObject = { [prop: string]: string };
    // 解析url参数
    const paramMap: TstrObject = {};
    const params = location.search.slice(1).split('&');

    for (let item of params) {
        if (!item) {
            continue;
        }
        const arr: string[] = item.split('=');
        if (arr.length > 1) {
            paramMap[arr[0]] = arr[1];
        }
    }

    return paramMap;
})();

export const ajaxHeaders = (() => {
    const SIGN = 'c8bce0340a824c27983a8e311f93410e';
    const headers = {
        sign: SIGN,
        'x-client': 'android',
        'x-dev-id': '',
        'x-origin-url': location.href,
        'x-enter-page-sign': Date.now() + '' + Math.round(Math.random() * 10000),
    };

    return headers;
})();

